﻿using SD.Common.PoweredByLee;
using SD.ContentSystem.Domain.Entities;
using SD.ContentSystem.IAppService.DTOs.Outputs;
using System.Collections.Generic;

namespace SD.ContentSystem.AppService.Maps
{
    /// <summary>
    /// 文章映射工具类
    /// </summary>
    public static class ArticleMap
    {
        #region # 文章映射 —— static ArticleInfo ToDTO(this Article article...
        /// <summary>
        /// 文章映射
        /// </summary>
        /// <param name="article">文章领域模型</param>
        /// <param name="channelInfos">栏目字典</param>
        /// <returns>文章数据传输对象</returns>
        public static ArticleInfo ToDTO(this Article article, IDictionary<string, ChannelInfo> channelInfos)
        {
            ArticleInfo articleInfo = Transform<Article, ArticleInfo>.Map(article);
            articleInfo.ChannelInfo = channelInfos[article.ChannelNo];

            return articleInfo;
        }
        #endregion

        #region # 栏目映射 —— static ChannelInfo ToDTO(this Channel channel)
        /// <summary>
        /// 栏目映射
        /// </summary>
        /// <param name="channel">栏目领域模型</param>
        /// <returns>栏目数据传输对象</returns>
        public static ChannelInfo ToDTO(this Channel channel)
        {
            ChannelInfo channelInfo = Transform<Channel, ChannelInfo>.Map(channel);

            return channelInfo;
        }
        #endregion
    }
}